﻿using System.Windows.Controls;
using Cirrious.MvvmCross.Interfaces.ViewModels;
using Cirrious.MvvmCross.Wpf.Interfaces;
using TeaLightV5.Foundation.UX.ViewModels;

namespace TeaLightV5.Foundation.UX.Wpf.Views
{
    public abstract class EntityView : UserControl, IMvxWpfView
    {
        private IMvxViewModel _viewModel;
        public IMvxViewModel ViewModel
        {
            get { return _viewModel; }
            set
            {
                _viewModel = value;
                DataContext = value;
                EntityViewModel baseViewModel = ViewModel as EntityViewModel;
                if (baseViewModel != null)
                {
                    // todo Refactor ReloadModel
                    baseViewModel.ReloadModel();
                }
            }
        }
    }
}
